home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
gui
/
popup
/
popupstack.pyo
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
133 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import wx
from wx import Point, RectPS, TOP, BOTTOM, LEFT, RIGHT
from traceback import print_exc
from gui.toolbox import Monitor, alignment_to_string
from gui.windowfx import move_smoothly
from cgui import fadein, fadeout
from common import prefprop, pref
from logging import getLogger
log = getLogger('popupstack')
def screenArea(monitor_n):
display_n = min(Monitor.GetCount() - 1, monitor_n)
return Monitor.All()[display_n].GetClientArea()
class PopupStack(list):
def __init__(self, monitor, position, padding = None, border = None):
self.monitor = monitor
self.corner = position
if padding is None:
padding = (0, 10)
if border is None:
border = (10, 10)
self.padding = Point(*padding)
self.border = Point(*border)
self.NextRect = None if TOP & self.corner else self.Up
self.OppositeRect = None if TOP & self.corner else self.Down
def __repr__(self):
return '<PopupStack %s monitor %d (%d popups)>' % (alignment_to_string(self.corner), self.monitor, len(self))
def ScreenRect(self):
return screenArea(self.monitor)
ScreenRect = property(ScreenRect)
def Up(self, prevRect, newSize):
border = self.border
padding = self.padding
if prevRect is None:
if LEFT & self.corner:
pt = self.ScreenRect.BottomLeft + (border.x + padding.x, -(border.y))
else:
pt = self.ScreenRect.BottomRight - (newSize.width + border.x + padding.x, border.y)
else:
pt = prevRect.TopLeft - Point(0, border.y + padding.y)
return RectPS(pt - Point(0, newSize.height), newSize)
def Down(self, prevRect, newSize):
border = self.border
padding = self.padding
if prevRect is None:
if LEFT & self.corner:
pt = self.ScreenRect.TopLeft + (border.x + padding.x, border.y)
else:
pt = self.ScreenRect.TopRight - (newSize.width + border.x + padding.x, -(border.y))
else:
pt = prevRect.BottomLeft + Point(0, border.y + padding.y)
return RectPS(pt, newSize)
def InitialPos(self, size):
return self.NextRect(None, size).Position
def Add(self, popup):
self.append(popup)
(popup, popup.OnClose) += (lambda userClose: self.Remove(popup))
self.DoPositions(popup)
popup._infader = fadein(popup, 0, popup.opacity_normal, 30)
def Remove(self, popup):
try:
self.remove(popup)
except ValueError:
pass
self.DoPositions()
def DoPositions(self, paging = None):
prevRect = None
for popup in self[:]:
try:
oldrect = popup.Rect
except wx.PyDeadObjectError:
self.remove(popup)
log.critical('dead Popup object in %r' % self)
continue
quick = False
desired = popup.DesiredSize
if popup.Hover or popup.has_focus:
rect = RectPS(popup.Position, desired)
if paging is popup:
rect.y -= rect.height - oldrect.height
else:
rect = self.NextRect(prevRect, desired)
popup._moved = True
self.SetPopupRect(popup, rect, quick = paging is popup)
prevRect = rect
slidetime = prefprop('notifications.popups.slide_ms', 140)
def SetPopupRect(self, popup, rect, quick = False):
t = int(self.slidetime)
if t == 0:
quick = True
oldrect = popup.Rect
if quick:
popup.SetRect(rect)
elif oldrect.Size != rect.Size:
popup.SetRect(oldrect.Position, rect.Size)
move_smoothly(popup, rect.Position, time = t)